package com.leetcode.LC;

import java.util.HashSet;
import java.util.List;

public class LC1436 {
    public String destCity(List<List<String>> paths) {
        //把起点和终点做成两个集合，然后终点集减去起点集，剩下的一个元素就是结果
        HashSet<String> set = new HashSet<>();
        for (List<String> path : paths) {
            set.add(path.get(0));
        }
        for (List<String> path : paths) {
            if (!set.contains(path.get(1))) {
                return path.get(1);
            }
        }
        return "";
    }
}
